package com.pactera.asmp.server.restfullapi;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.pactera.asmp.server.common.annotations.JwtIgnore;
import com.pactera.asmp.server.entity.CameraInfoDTO;
import com.pactera.asmp.server.entity.ResponseResult;
import com.pactera.asmp.server.service.ICameraService;

@RestController
@RequestMapping("/terminal/camera/api/v1")
public class RestfulCameraApi {

    private static final Logger logger = LoggerFactory.getLogger(RestfulCameraApi.class);

    @Autowired
    private ICameraService cameraService;

    // 注册摄像头设备
    @JwtIgnore
    @PostMapping(value = "/register",produces = "application/json;charset=UTF-8")
    private ResponseResult registerCamera(@RequestBody CameraInfoDTO cameraInfoDTO) {
        logger.info("POST /terminal/camera/api/v1/register registerCamera");
        return cameraService.registerCamera(cameraInfoDTO);
    }

    // 摄像头离线
    @JwtIgnore
    @PostMapping(value = "/offline",produces = "application/json;charset=UTF-8")
    private ResponseResult offlineCamera(@RequestBody CameraInfoDTO cameraInfoDTO) {
        logger.info("POST /terminal/camera/api/v1/offline offlineCamera");
        return cameraService.offlineCamera(cameraInfoDTO);
    }

    // 摄像头占用
    @JwtIgnore
    @PostMapping(value = "/occupy",produces = "application/json;charset=UTF-8")
    private ResponseResult occupyCamera(@RequestBody CameraInfoDTO cameraInfoDTO) {
        logger.info("POST /terminal/camera/api/v1/occupy occupyCamera");
        return cameraService.occupyCamera(cameraInfoDTO);
    }

    // 摄像头解除占用
    @PostMapping(value = "/inOccupy",produces = "application/json;charset=UTF-8")
    private ResponseResult inOccupyCamera(@RequestBody CameraInfoDTO cameraInfoDTO) {
        logger.info("POST /terminal/camera/api/v1/inOccupy inOccupyCamera");
        return cameraService.inOccupyCamera(cameraInfoDTO);
    }
}
